<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index()
    {
        $this->display();
    }
    //显示books表  books.html
    public function book(){

        $booksmodel=M('books');
        $count=$booksmodel->count();
        $classmodel=M('class');
        $signsmodel=M('signs');
        $usermodel=M('users');
        $class=$classmodel->order('cid asc')->select();
        $signs=$signsmodel->order('sid asc')->limit('3')->select();
        $users=$usermodel->order('id asc')->select();
        $this->class=$class;
        $this->signs=$signs;
        $this->users=$users;
        $Page=new \Think\Page($count,6);
        //修改显示
        $Page->setConfig('prev','上一页');
        $Page->setConfig('next','下一页');
        $Page->setConfig('theme','%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%');
        $respage=$Page->show();
        $this->page=$respage;
        $this->books=$booksmodel->order('bid asc')->limit($Page->firstRow.','.$Page->listRows)->select();
        //var_dump($practicesmodel);
        $this->display();
    }
    //显示book1表  books1.html
    public function book1($bid){
        $booksmodel= M('books');
        $signs = $booksmodel->join('RIGHT JOIN signs ON books.sid = signs.sid' );
        $class= $signs->join('RIGHT JOIN class ON class.cid = signs.cid' );
        $books = $class->where ("bid=$bid") ->find();
        $this->books = $books;
        $this->display();
    }

}